package transaction.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import transaction.mapper.UserLogMapper;
import transaction.model.UserLog;

/**
 * @Author quan
 * @Description TODO
 * @Date 2023/7/31 11:11
 */

@Service
public class UserLogService {
    @Autowired
    private UserLogMapper userLogMapper;
    @Transactional(propagation = Propagation.NESTED)
    public Integer insertLog(UserLog userLog){
        int a = 10/0;
//        try {
//            int a = 10/0;
//        } catch(Exception e){
//            // ⼿动回滚事务
//            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//        }
        return userLogMapper.insertLog(userLog);
    }
}
